import { reactive, ref } from "vue";
import { getAllCountryApi } from "@/api/configCenter/countryRegion";
export default function InitHook() {
  const formState = reactive<Partial<WarehouseCode.AddForm>>({
    warehouseType: undefined,
    warehouseProperty: undefined,
    countryId: undefined,
    warehouseCode: undefined,
    city: undefined,
    state: undefined,
    zipCode: undefined,
    receiverName: undefined,
    receiverPhone: undefined,
    company: undefined,
    address: undefined,
    addressTwo: undefined,
    addressThree: undefined,
    status: 1
  });
  const loading = ref<boolean>(false);
  const formDataRef = ref<any>(null);
  const countryOpts = ref<Array<Base.GeneraDataType>>([]);
  const getAllCountryOpts = () => {
    return getAllCountryApi(1).then((res: any) => {
      const { code, data } = res;
      if (code === 200) {
        countryOpts.value = data || [];
      }
    });
  };
  return {
    formState,
    formDataRef,
    loading,
    countryOpts,
    getAllCountryOpts
  };
}
